package com.pinyoumei.app.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.pinyoumei.app.R;
import com.pinyoumei.app.bean.WmListBean;
import com.pinyoumei.app.network.Constants;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2020-12-22.
 * --------- 日期 ------- 维护人 ------------ 变更内容 --------
 * 2020-12-22        Administrator             新增Person类
 * 2020-12-22        Administrator             增加sex属性
 */
public class WmListAdapter extends BaseQuickAdapter<WmListBean.ResultBean.ActivityListBean, BaseViewHolder> {
    public WmListAdapter(int layoutResId, @Nullable List<WmListBean.ResultBean.ActivityListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, WmListBean.ResultBean.ActivityListBean item) {
        helper.addOnClickListener(R.id.ll_get);
        helper.addOnClickListener(R.id.iv_share);



        RequestOptions placeholder = new RequestOptions().placeholder(R.mipmap.ic_error_loading);
        ImageView imageView =  helper.getView(R.id.iv_shop_bg);
        switch (item.getActivity_source()) {
//            活动来源：1.美团 2.饿了么
        	case 1:
                imageView.setImageResource(R.mipmap.ic_wm_type_1);
        		break;
            case 2:
                imageView.setImageResource(R.mipmap.ic_wm_type_2);
                break;
        	default:
        		break;
        }

        helper.setText(R.id.tv_title,item.getActivity_title());
        helper.setText(R.id.tv_commission_rate,"领券下单拿返佣 最高" + item.getCommission_rate());





        ImageView iv_share =  helper.getView(R.id.iv_share);

        Glide.with(mContext).load(Constants.MAIN_URL + item.getActivity_img()).apply(placeholder).into(iv_share);
    }
}
